/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.jr2tecnologia.model.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author ronildo
 */
@Entity
@Table(name = "bank_account")
@NamedQueries({
    @NamedQuery(name = "BankAccount.findAll", query = "SELECT b FROM BankAccount b"),
    @NamedQuery(name = "BankAccount.findByPkBankAccount", query = "SELECT b FROM BankAccount b WHERE b.pkBankAccount = :pkBankAccount"),
    @NamedQuery(name = "BankAccount.findByName", query = "SELECT b FROM BankAccount b WHERE b.name = :name"),
    @NamedQuery(name = "BankAccount.findByBalance", query = "SELECT b FROM BankAccount b WHERE b.balance = :balance"),
    @NamedQuery(name = "BankAccount.findByDefaultBankAccount", query = "SELECT b FROM BankAccount b WHERE b.defaultBankAccount = :defaultBankAccount"),
    @NamedQuery(name = "BankAccount.findByQuantitySmsBuyed", query = "SELECT b FROM BankAccount b WHERE b.quantitySmsBuyed = :quantitySmsBuyed")})
public class BankAccount implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "pk_bank_account")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_bank_account")
    @SequenceGenerator(name="seq_bank_account", sequenceName="seq_bank_account", allocationSize=1)
    private Long pkBankAccount;

    @Basic(optional = false)
    @Column(name = "name")
    private String name;

    @Basic(optional = false)
    @Column(name = "balance")
    private Double balance;

    @Basic(optional = false)
    @Column(name = "default_bank_account")
    private boolean defaultBankAccount;

    @Basic(optional = false)
    @Column(name = "quantity_sms_buyed")
    private Long quantitySmsBuyed;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bankAccount")
    private List<Login> loginList;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bankAccount")
    private List<Credit> creditList;

    @JoinColumn(name = "fk_company", referencedColumnName = "pk_company")
    @ManyToOne(optional = false)
    private Company company;

    public BankAccount() {
    }

    public BankAccount(Long pkBankAccount) {
        this.pkBankAccount = pkBankAccount;
    }

    public BankAccount(Company company) {
        this.company = company;
    }

    public BankAccount(Long pkBankAccount, String name, Double balance, boolean defaultBankAccount, Long quantitySmsBuyed) {
        this.pkBankAccount = pkBankAccount;
        this.name = name;
        this.balance = balance;
        this.defaultBankAccount = defaultBankAccount;
        this.quantitySmsBuyed = quantitySmsBuyed;
    }

    public Long getPkBankAccount() {
        return pkBankAccount;
    }

    public void setPkBankAccount(Long pkBankAccount) {
        this.pkBankAccount = pkBankAccount;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    public boolean getDefaultBankAccount() {
        return defaultBankAccount;
    }

    public void setDefaultBankAccount(boolean defaultBankAccount) {
        this.defaultBankAccount = defaultBankAccount;
    }

    public Long getQuantitySmsBuyed() {
        return quantitySmsBuyed;
    }

    public void setQuantitySmsBuyed(Long quantitySmsBuyed) {
        this.quantitySmsBuyed = quantitySmsBuyed;
    }

    public List<Login> getLoginList() {
        return loginList;
    }

    public void setLoginList(List<Login> loginList) {
        this.loginList = loginList;
    }

    public List<Credit> getCreditList() {
        return creditList;
    }

    public void setCreditList(List<Credit> creditList) {
        this.creditList = creditList;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pkBankAccount != null ? pkBankAccount.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BankAccount)) {
            return false;
        }
        BankAccount other = (BankAccount) object;
        if ((this.pkBankAccount == null && other.pkBankAccount != null) || (this.pkBankAccount != null && !this.pkBankAccount.equals(other.pkBankAccount))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.jr2tecnologia.model.entity.BankAccount[pkBankAccount=" + pkBankAccount + "]";
    }
}
